package com.my.zl.console.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.my.zl.common.dto.ReqDTO;
import com.my.zl.common.dto.ResDTO;
import com.my.zl.common.dto.advancedQuery.PageQueryDTO;
import com.my.zl.console.common.aop.LogAnnotation;
import com.my.zl.console.controller.base.BaseController;
import com.my.zl.console.entity.autocode.ZlTemplate;
import com.my.zl.console.dto.autocode.template.ReqTemplateAddDTO;
import com.my.zl.console.dto.autocode.template.ReqTemplateDelDTO;
import com.my.zl.console.dto.autocode.template.ReqTemplateEditDTO;
import com.my.zl.console.dto.autocode.template.ReqTemplateQueryDTO;
import com.my.zl.console.dto.autocode.template.ReqTemplateDetailDTO;
import com.my.zl.console.dto.autocode.template.ReqTemplateStateDTO;
import com.my.zl.console.dto.autocode.template.ResTemplateAddDTO;
import com.my.zl.console.dto.autocode.template.ResTemplateDelDTO;
import com.my.zl.console.dto.autocode.template.ResTemplateEditDTO;
import com.my.zl.console.dto.autocode.template.ResTemplateQueryDTO;
import com.my.zl.console.dto.autocode.template.ResTemplateDetailDTO;
import com.my.zl.console.service.autocode.ITemplateService;
import com.my.zl.console.dto.autocode.template.ResTemplateStateDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 模板信息
 * @author ZL
 */
@Api(value="模板信息",tags ="模板信息")
@RestController
@RequestMapping("/api/autocode/template")
public class TemplateController extends BaseController {

    @Autowired
    private ITemplateService templateService;
    
    /**
     * 查询
     */
    @ApiOperation(value="模板信息-查询")
    @RequestMapping(value="/list", method = RequestMethod.GET)
    public ResDTO<ResTemplateQueryDTO> listTemplate(ReqTemplateQueryDTO reqInfo,PageQueryDTO page) throws Exception{
        ResTemplateQueryDTO data = templateService.queryTemplateList(reqInfo,page);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="模板信息-详情")
    @RequestMapping(value="/detail", method = RequestMethod.GET)
    public ResDTO<ResTemplateDetailDTO> detailTemplate(ReqTemplateDetailDTO reqInfo) throws Exception{
        ResTemplateDetailDTO data = templateService.queryTemplateDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="模板信息-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public ResDTO<ResTemplateAddDTO> addTemplate(@RequestBody ReqDTO<ReqTemplateAddDTO> reqInfo) throws Exception{
        ResTemplateAddDTO data = templateService.insertTemplateInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="模板信息-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
    public ResDTO<ResTemplateEditDTO> editTemplate(@RequestBody ReqDTO<ReqTemplateEditDTO> reqInfo) throws Exception{
        ResTemplateEditDTO data = templateService.updateTemplateInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="模板信息-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
    public ResDTO<ResTemplateDelDTO> delTemplate(@RequestBody ReqDTO<ReqTemplateDelDTO> reqInfo) throws Exception{
        ResTemplateDelDTO data = templateService.deleteTemplateInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="模板信息-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
    public ResDTO<ResTemplateStateDTO> stateTemplate(@RequestBody ReqDTO<ReqTemplateStateDTO> reqInfo) throws Exception{
        ResTemplateStateDTO data = templateService.updateTemplateState(reqInfo);
        return successDATA(data); 
    }
    
    
}